/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.gad.ui;

import java.awt.*;
import org.gad.model.Step;
import org.netbeans.api.visual.action.ActionFactory;
import org.netbeans.api.visual.border.BorderFactory;
import org.netbeans.api.visual.layout.LayoutFactory;
import org.netbeans.api.visual.widget.LabelWidget;
import org.netbeans.api.visual.widget.Widget;

/**
 *
 * @author Tomek
 */
public abstract class StepWidgetBase extends Widget {
    
    
    protected BoxScene _scene;
    protected Widget _mainVFlow;
    protected Widget _headerVFlow;
    protected LabelWidget _label;
    protected ButtonWidget _deleteButton;
    protected CompositeStepWidget _parent;
    protected Step _modelStep;
    
    public StepWidgetBase(BoxScene scene, Step modelStep) {
        super (scene);
        _scene = scene;
        _modelStep = modelStep;
        this.setMinimumSize( Dimensions.StepMinSize );
        
        setLayout (LayoutFactory.createOverlayLayout());
        
        _mainVFlow = new Widget( scene );
        _mainVFlow.setLayout(Layouts.VerticalLayout);
        this.addChild(_mainVFlow);
        
        _headerVFlow = new Widget( scene );
        _headerVFlow.setLayout(Layouts.HorizontalLayout);
        //_headerVFlow.setBorder( new BottomBorder());
        
        _label = new LabelWidget (scene, modelStep.getName());
        _label.setOpaque(false);
        _label.setBackground( new Color(187,233,255));
        _label.setMinimumSize( new Dimension( 80, 10 ));
        _label.setAlignment(LabelWidget.Alignment.CENTER);
        
        _deleteButton = new ButtonWidget(scene, "-", new IButtonClickListener() {
        
            public void Click()
            {
                if( StepWidgetBase.this._parent != null )
                    _parent.removeInnerStep(StepWidgetBase.this);
            }
        });
        
        this.getActions().addAction(ActionFactory.createMoveAction( new MyMoveStrategy(scene), 
                new MyMoveProvider(scene)));
        
        
        _headerVFlow.addChild ( _label  ); 
        _headerVFlow.addChild(_deleteButton);
         _mainVFlow.addChild(_headerVFlow);
        this.setBorder(BorderFactory.createLineBorder(1, Color.LIGHT_GRAY) );


        

    }


}
